home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWGDlist.z / RWGDlist
Encoding:
Text File  |  2002-10-03  |  11.7 KB  |  331 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))                                                  RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWGDlist(type) - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/gdlist.h>
  13.  
  14.  
  15.  
  16.               declare(RWGDlist, type)
  17.           RWGDlist(type) a;
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWGGGGDDDDlllliiiisssstttt((((ttttyyyyppppeeee)))) represents a group of ordered elements of type ttttyyyyppppeeee,
  24.      not accessible by an external key.  Duplicates are allowed.  This class
  25.      is implemented as a doubly-linked list.  Objects of type RRRRWWWWGGGGDDDDlllliiiisssstttt((((ttttyyyyppppeeee))))
  26.      are declared with macros defined in the standard C++ header file
  27.      <<<<ggggeeeennnneeeerrrriiiicccc....hhhh>>>>.  In order to find a particular item within the collection, a
  28.      user-provided global "tester" function is required to test for a "match,"
  29.      definable in any consistent way.  This function should have prototype:
  30.  
  31.               RWBoolean yyyyoooouuuurrrrTTTTeeeesssstttteeeerrrrFFFFuuuunnnnccccttttiiiioooonnnn(const ttttyyyyppppeeee* c, const void* d);
  32.  
  33.  
  34.  
  35.  
  36.  
  37.      The argument cccc is a candidate within the collection to be tested for a
  38.      match.  The argument dddd is for your convenience and will be passed to
  39.      yyyyoooouuuurrrrTTTTeeeesssstttteeeerrrrFFFFuuuunnnnccccttttiiiioooonnnn(((()))).  The function should return TTTTRRRRUUUUEEEE if a "match" is
  40.      found between cccc and dddd.  In order to simplify the documentation below, an
  41.      imaginary typedef
  42.  
  43.               typedef RWBoolean (*yyyyoooouuuurrrrTTTTeeeesssstttteeeerrrr)(const ttttyyyyppppeeee*, const void*);
  44.  
  45.  
  46.  
  47.  
  48.  
  49.      has been used for this tester function.
  50.  
  51. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  52.      None
  53.  
  54. EEEExxxxaaaammmmpppplllleeee
  55.               #include <rw/gdlist.h>
  56.           #include <rw/rstream.h>
  57.           declare(RWGDlist,int)    /* Declare a list of ints */
  58.           main()  {
  59.             RWGDlist(int) list;    // Define a list of ints
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))                                                  RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.             int *ip;
  75.             list.insert(new int(5));   // Insert some ints
  76.             list.insert(new int(7));
  77.             list.insert(new int(1));
  78.             list.prepend(new int(11));
  79.             RWGDlistIterator(int) next(list);
  80.             while(ip = next() )
  81.               cout << *ip << endl;   // Print out the members
  82.             while(!list.isEmpty())
  83.               delete list.get();     // Remove & delete list items
  84.             return 0;
  85.           }
  86.  
  87.  
  88.      Program output:
  89.  
  90.                    11
  91.                5
  92.                7
  93.                1
  94.  
  95.  
  96.  
  97. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  98.               RWGDlist(ttttyyyyppppeeee)();
  99.  
  100.  
  101.      Construct an empty collection.
  102.  
  103.               RWGDlist(ttttyyyyppppeeee)(ttttyyyyppppeeee* a);
  104.  
  105.  
  106.      Construct a collection with one entry aaaa.
  107.  
  108.               RWGDlist(ttttyyyyppppeeee)(const RWGDlist(ttttyyyyppppeeee)& a);
  109.  
  110.  
  111.      Copy constructor.  A shallow copy of aaaa is made.
  112.  
  113. AAAAssssssssiiiiggggnnnnmmmmeeeennnntttt OOOOppppeeeerrrraaaattttoooorrrr
  114.               void
  115.           ooooppppeeeerrrraaaattttoooorrrr====(const RWGDlist(ttttyyyyppppeeee)& a);
  116.  
  117.  
  118.      Assignment operator.  A shallow copy of aaaa is made.
  119.  
  120. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  121.               ttttyyyyppppeeee****
  122.           aaaappppppppeeeennnndddd(type* a);
  123.  
  124.  
  125.      Adds an item to the end of the collection.  Returns nnnniiiillll if the insertion
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))                                                  RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      was unsuccessful.
  141.  
  142.               void
  143.           aaaappppppppllllyyyy(void (*ap)(ttttyyyyppppeeee*, void*), void* );
  144.  
  145.  
  146.      Visits all the items in the collection in order, from first to last,
  147.      calling the user-provided function pointed to by aaaapppp for each item.  This
  148.      function should have prototype:
  149.  
  150.               void yyyyoooouuuurrrrAAAAppppppppllllyyyyFFFFuuuunnnnccccttttiiiioooonnnn(ttttyyyyppppeeee**** c, void*);
  151.  
  152.  
  153.  
  154.  
  155.  
  156.      and can perform any operation on the object at address cccc.  The last
  157.      argument is useful for passing data to the apply function.
  158.  
  159.               ttttyyyyppppeeee*&
  160.           aaaatttt(size_t i);
  161.           const ttttyyyyppppeeee*
  162.           aaaatttt(size_t i) const;
  163.  
  164.  
  165.      Returns a pointer to the iiiith item in the collection.  The first variant
  166.      can be used as an lvalue, the second cannot.  The index iiii must be between
  167.      zero and the number of items in the collection less one, or an exception
  168.      of type TTTTOOOOOOOOLLLL____IIIINNNNDDDDEEEEXXXX will be thrown.
  169.  
  170.               void
  171.           cccclllleeeeaaaarrrr();
  172.  
  173.  
  174.      Removes all items in the collection.
  175.  
  176.               RWBoolean
  177.           ccccoooonnnnttttaaaaiiiinnnnssss(yyyyoooouuuurrrrTTTTeeeesssstttteeeerrrr t, const void* d) const;
  178.  
  179.  
  180.      Returns TTTTRRRRUUUUEEEE if the collection contains an item for which the user-
  181.      defined function pointed to by tttt finds a match with dddd.
  182.  
  183.               RWBoolean
  184.           ccccoooonnnnttttaaaaiiiinnnnssssRRRReeeeffffeeeerrrreeeennnncccceeee(const ttttyyyyppppeeee* e) const;
  185.  
  186.  
  187.      Returns TTTTRRRRUUUUEEEE if the collection contains an item with the address eeee....
  188.  
  189.               size_t
  190.           eeeennnnttttrrrriiiieeeessss() const;
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))                                                  RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Returns the number of items in the collection.
  207.  
  208.               ttttyyyyppppeeee*
  209.           ffffiiiinnnndddd(yyyyoooouuuurrrrTTTTeeeesssstttteeeerrrr t, const void* d) const;
  210.  
  211.  
  212.      Returns the first item in the collection for which the user-provided
  213.      function pointed to by tttt finds a match with dddd, or nnnniiiillll if no item is
  214.      found.
  215.  
  216.               ttttyyyyppppeeee*
  217.           ffffiiiinnnnddddRRRReeeeffffeeeerrrreeeennnncccceeee(const type* e) const;
  218.  
  219.  
  220.      Returns the first item in the collection with the address eeee, or nnnniiiillll if no
  221.      item is found.
  222.  
  223.               ttttyyyyppppeeee*
  224.           ffffiiiirrrrsssstttt() const;
  225.  
  226.  
  227.      Returns the first item of the collection.
  228.  
  229.               ttttyyyyppppeeee*
  230.           ggggeeeetttt();
  231.  
  232.  
  233.      Returns and rrrreeeemmmmoooovvvveeeessss the first item of the collection.
  234.  
  235.               ttttyyyyppppeeee*
  236.           iiiinnnnsssseeeerrrrtttt(ttttyyyyppppeeee* e);
  237.  
  238.  
  239.      Adds an item to the end of the collection and returns it.  Returns nnnniiiillll if
  240.      the insertion was unsuccessful.
  241.  
  242.               void
  243.           iiiinnnnsssseeeerrrrttttAAAAtttt(size_t indx, ttttyyyyppppeeee**** e);
  244.  
  245.  
  246.      Adds a new item to the collection at position iiiinnnnddddxxxx.  The item previously
  247.      at position iiii is moved to iiii++++1111, eeeettttcccc.  The index iiiinnnnddddxxxx must be between 0 and
  248.      the number of items in the collection, or an exception of type TTTTOOOOOOOOLLLL____IIIINNNNDDDDEEEEXXXX
  249.      will be thrown.
  250.  
  251.               RWBoolean
  252.           iiiissssEEEEmmmmppppttttyyyy() const;
  253.  
  254.  
  255.      Returns TTTTRRRRUUUUEEEE if the collection is empty, otherwise FFFFAAAALLLLSSSSEEEE.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))                                                  RRRRWWWWGGGGDDDDlllliiiisssstttt((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.               ttttyyyyppppeeee*
  273.           llllaaaasssstttt() const;
  274.  
  275.  
  276.      Returns the last item of the collection.
  277.  
  278.               size_t
  279.           ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(yyyyoooouuuurrrrTTTTeeeesssstttteeeerrrr t, const void* d) const;
  280.  
  281.  
  282.      Returns the number of occurrences in the collection for which the user-
  283.      provided function pointed to by tttt finds a match with dddd.
  284.  
  285.               size_t
  286.           ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffffRRRReeeeffffeeeerrrreeeennnncccceeee(const ttttyyyyppppeeee* e) const;
  287.  
  288.  
  289.      Returns the number of items in the collection with the address eeee....
  290.  
  291.               ttttyyyyppppeeee*
  292.           prepend(type* a);
  293.  
  294.  
  295.      Adds an item to the beginning of the collection.  Returns nnnniiiillll if the
  296.      insertion was unsuccessful.
  297.  
  298.               ttttyyyyppppeeee*
  299.           rrrreeeemmmmoooovvvveeee(yyyyoooouuuurrrrTTTTeeeesssstttteeeerrrr t, const void* d);
  300.  
  301.  
  302.      Removes and returns the first item from the collection for which the
  303.      user-provided function pointed to by tttt finds a match with dddd, or returns
  304.      nnnniiiillll if no item is found.
  305.  
  306.               ttttyyyyppppeeee*
  307.           rrrreeeemmmmoooovvvveeeeRRRReeeeffffeeeerrrreeeennnncccceeee(const type* e);
  308.  
  309.  
  310.      Removes and returns the first item from the collection with the address
  311.      eeee, or returns nnnniiiillll if no item is found.
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.